<template>
  <div class="content-box">
    <div class="tab-box flex ac">
      <div
        @click="tabActive = item.id"
        :class="tabActive == item.id ? 'tab-items-active' : ''"
        v-for="item in tabList"
        :key="item.id"
        class="tab-items flex ac jc"
      >
        {{ `${item.name} ${item.num}` }}
      </div>
    </div>
    <div class="padding-box">
      <div class="search-box">
        <el-form
          :inline="true"
          :model="searchFormInline"
          class="demo-form-inline"
        >
          <el-form-item label="">
            <el-input
              v-model="searchFormInline.user"
              placeholder="请输入订单编号"
              clearable
              class="input-box"
            />
          </el-form-item>
          <el-form-item label="">
            <el-input
              v-model="searchFormInline.user"
              placeholder="请输入手机号"
              clearable
              class="input-box"
            />
          </el-form-item>
          <el-form-item label="">
            <el-input
              v-model="searchFormInline.user"
              placeholder="请输入店铺名称"
              clearable
              class="input-box"
            />
          </el-form-item>
          <el-form-item label="">
            <el-date-picker
              v-model="searchFormInline.value2"
              type="daterange"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :shortcuts="shortcuts"
              class="input-box"
            />
          </el-form-item>
          <el-form-item>
            <el-button class="search-btn" type="primary" @click="">
              查询
            </el-button>
            <el-button class="data-btn" :icon="Document">数据导出</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div class="table-box">
        <el-table
          :data="tableData"
          height="100%"
          stripe
          :header-cell-style="{
            color: '#828A9D',
            textAlign: 'center',
            height: '60px',
          }"
          :cell-style="{ textAlign: 'center', color: '#1B2431' }"
        >
          <el-table-column prop="date" label="订单编号" />
          <el-table-column prop="name" label="租借手机号" />
          <el-table-column prop="state" label="租借店铺" />
          <el-table-column prop="city" label="租借时间" sortable />
          <el-table-column prop="address" label="租借时长" sortable />
          <el-table-column prop="zip" label="订单金额" sortable />
          <el-table-column prop="zip" label="当前状态">
            <template #default="scope">
              <!-- <el-tag type="primary">已退款</el-tag>
              <el-tag type="success">进行中</el-tag>
              <el-tag type="info">已完结</el-tag>
              <el-tag type="warning">已暂停</el-tag> -->
              <el-tag type="danger">待付款</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="zip" label="操作">
            <template #default="scope">
              <el-button type="primary" link @click="dialogVisible = true">
                详情
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="pagination-box flex jc">
        <el-pagination
          v-model:page-size="searchForm.pageSize"
          v-model:current-page="searchForm.page"
          :total="searchForm.totalAll"
          @change="sizePageChangeFunc"
          background
          layout="total,sizes,prev, pager, next,jumper"
        />
      </div>
    </div>
  </div>
  <!-- 详情 -->
  <orderDetail
    :show="dialogVisible"
    @onClose="dialogVisible = false"
    typeStr="order"
  ></orderDetail>
</template>
<script setup>
import { onMounted, reactive, toRefs, ref } from 'vue'
import { Document } from '@element-plus/icons-vue'
import orderDetail from '@/components/orderDetail/index.vue'
onMounted(() => {
  console.log('index')
})
let dialogVisible = ref(false)
let searchForm = ref({
  pageSize: 10,
  page: 1,
  totalAll: 0,
})
const sizePageChangeFunc = e => {
  console.log(searchForm.value)
}
let tableData = ref([
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
])
const shortcuts = [
  {
    text: '最近一周',
    value: () => {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      return [start, end]
    },
  },
  {
    text: '最近一个月',
    value: () => {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      return [start, end]
    },
  },
  {
    text: '最近三个月',
    value: () => {
      const end = new Date()
      const start = new Date()
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
      return [start, end]
    },
  },
]
let searchFormInline = ref({})
let tabActive = ref(1)
let tabList = ref([
  {
    name: '进行中',
    num: 3,
    id: 1,
  },
  {
    name: '已完结',
    num: 213,
    id: 2,
  },
  {
    name: '已暂停',
    num: 433,
    id: 3,
  },
  {
    name: '待付款',
    num: 354,
    id: 4,
  },
  {
    name: '已退款',
    num: 366,
    id: 5,
  },
])
</script>
<style scoped lang="scss">
@import './index.scss';
</style>